package com.dycloud.project.controller.user;

import com.dycloud.project.aspectj.lang.annotation.Log;
import com.dycloud.project.aspectj.lang.enums.BusinessType;
import com.dycloud.project.aspectj.lang.enums.OperatorType;
import com.dycloud.project.interceptor.annotation.RepeatSubmit;
import com.dycloud.project.request.LoginRequest;
import com.dycloud.project.service.UserLoginService;
import com.dycloud.project.web.domain.AjaxResult;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : renhang
 * @description AuthController
 * @date : 2025-05-27 09:57
 **/
@RestController
@RequestMapping("/user/auth")
public class AuthController {


    @Resource
    private UserLoginService userLoginService;

    @PostMapping("/login")
    @Log(title = "微信登录", operatorType = OperatorType.MOBILE, businessType = BusinessType.LOGIN)
    @RepeatSubmit(interval = 1500)
    public AjaxResult login(@RequestBody @Validated LoginRequest request) {
        return userLoginService.userCreatToken(request);
    }
}
